package user

import (
	"gitee.com/mirzatsoft/wakit/app"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"gorm.io/gorm"
)

type Module struct {
	db     *gorm.DB
	logger *zap.Logger
}

func NewModule() app.Module {
	return &Module{}
}

func (m *Module) Name() string {
	return "user"
}

func (m *Module) Init(c *app.WebAppContext) error {
	m.db = c.DB
	m.logger = c.Logger.Named("user")
	return nil
}

func (m *Module) Routes(g *gin.RouterGroup) {
	g.POST("/auth/password", RegisterWithPassword)
	g.POST("/auth/email", RegisterWithEmail)
	g.POST("/auth/wechat/mini", RegisterWithWechatMini)
}
